package com.share.hope.controller;

import com.alibaba.fastjson.JSONObject;
import com.share.hope.entity.result.R;
import com.share.hope.service.RecordInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/share/hope/record")
@RequiredArgsConstructor
@CrossOrigin
@Tag(name = "打卡信息管理接口")
public class RecordInfoController {

    private final RecordInfoService recordInfoService;


    @GetMapping("/punch_clock")
    @Operation(summary = "打卡")
    public R<String> punchTheClock(@RequestParam Long userId) {
        return recordInfoService.punchTheClock(userId);
    }

    @GetMapping("/get_punch")
    @Operation(summary = "查询打卡记录")
    public R<List<JSONObject>> getPunchMonth(@RequestParam Long userId, @RequestParam String date) {
        return recordInfoService.getPunchMonth(userId, date);
    }

    @GetMapping("/count")
    @Operation(summary = "查询连续签到/累计签到/最大连续")
    public R<JSONObject> getCount(@RequestParam Long userId) {
        return recordInfoService.getCount(userId);
    }
}
